<template>
  <div>
    <el-form @submit.native.prevent size="mini" v-if="NoCard()" :inline="true" :model="formInline"
             class="demo-form-inline">
      <el-form-item label="">
        <el-input show-password v-model="formInline.pwd" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">登录</el-button>
      </el-form-item>
    </el-form>

    <we v-else/>
  </div>
</template>

<script>
import Vue from "vue";
import we from "./we";
import moment from "moment";

export default {
  name: "weLogin",
  components: {we},
  data() {
    return {
      loginForm: {
        pwd: Vue.prototype.pwd,
      },
      formInline: {
        user: '',
        pwd: ''
      }
    }
  },
  methods: {
    showCard() {
      return this.loginForm.pwd === 'Aa@123456';
    },
    NoCard() {
      return this.loginForm.pwd !== 'Aa@123456';
    },
    onSubmit() {
      if (this.formInline.pwd === this.calculateTimeSum() + '') {
        Vue.prototype.pwd = 'Aa@123456';
        Vue.set(this.loginForm, 'pwd', 'Aa@123456');
      }
    },
    calculateTimeSum() {
      // 获取当前时间的小时和分钟
      const hour = moment().hour(); // 当前小时
      const minute = moment().minute(); // 当前分钟
      return hour + minute; // 计算和
    }
  }
}
</script>

<style scoped>

</style>
